package com.explorati.design_pattern.behavior.chainofresponsibility.example;

/**
 * 抽象处理者(Handler)角色：该角色对请求进行抽象，并定义一个方法以设定和返回对下一个处理者的引用
 * 
 * @author explorati
 *
 */
public abstract class Player {

	private Player successor;

	public abstract void handle(int i);

	protected void setSuccessor(Player aSuccessor) {
		successor = aSuccessor;
	}

	// 传给下一个
	public void next(int index) {
		if (successor != null) {
			successor.handle(index);
		} else {
			System.out.println("游戏结束");
		}
	}

}
